import React, { Component } from 'react'

class Child extends Component {
  render() {
    const { count } = this.props
    return (
      <div>
        <div>子组件 -- {count}</div>
      </div>
    )
  }
}

class App extends Component {
  count = 200

  addCount = () => {
    // console.log(this)
    this.count++
    // 强制更新视图
    this.forceUpdate()
  }

  render() {
    return (
      <div>
        <h3>父组件 -- {this.count}</h3>
        <hr />
        <Child count={this.count} />
        <hr />
        {/* 
          事件绑定的一定是一个函数体或方法体
        */}
        <button onClick={this.addCount}>++count++</button>
      </div>
    )
  }
}

export default App
